INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)

AUX_SOURCE_DIRECTORY(. LIBUNP_SRC)

# 如果開啟了 USE_READLINE_NOBUFFER 選項，即使用不帶緩沖的
# readline 函數，則將readline.c移出源文件列表，否則將
# 將readline1.c移出源文件列表。
IF (USE_READLINE_NOBUFFER)
  LIST(REMOVE_ITEM LIBUNP_SRC "./readline.c")
ELSE (USE_READLINE_NOBUFFER)
  LIST(REMOVE_ITEM LIBUNP_SRC "./readline1.c")
ENDIF (USE_READLINE_NOBUFFER)

# MESSAGE(STATUS "libunp的源文件列表：${LIBUNP_SRC}")

# ADD_LIBRARY(unp SHARED ${LIBUNP_SRC})
# ADD_LIBRARY(unp_static STATIC ${LIBUNP_SRC})
# SET_TARGET_PROPERTIES(unp_static PROPERTIES OUTPUT_NAME unp)
ADD_LIBRARY(unp ${LIBUNP_SRC})
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
  TARGET_LINK_LIBRARIES(unp sctp)
endif (CMAKE_SYSTEM_NAME STREQUAL "Linux")


SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

INSTALL(TARGETS unp
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
  DESTINATION include/unp/)